<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>新添书籍</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="author" content="夜读书">
    <meta name="description" content="夜读书中文网">
    <meta name="keywords" content="读书,阅读,小说,文学">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="{{ asset('/bootstrap-3.3.5-dist/css/bootstrap.min.css') }}">
    <link rel="stylesheet" href="{{ asset('/style/css/yds.css') }}">
    <link rel="stylesheet" href="{{ asset('/style/css/ucenter.css') }}">
    <script src="{{ asset('/scripts/jquery/jquery-1.11.3.min.js') }}"></script>
    <script src="{{ asset('/bootstrap-3.3.5-dist/js/bootstrap.min.js') }}"></script>
</head>
<body>
@include('books.partials.navtop')
@include('books.partials.nav')
<div id="yds_screen">
<div id="yds_content" class="clearfix">
  <div class="article">
   <h1>添加书籍</h1>
    <form name="form" class="form-horizontal" role="form" action="" method="post">
    <input type="hidden" name="_token" value="{{ csrf_token() }}" />
    <div class="form-group">
      <label for="firstname" class="col-sm-2 control-label">书名:*</label>
      <div class="col-sm-10">
         <input id="bookname" name="bookname" class="form-control input-lg" type="text" maxlength="150" placeholder="书名">
      </div>
    </div>
    <div class="form-group">
      <label for="lastname" class="col-sm-2 control-label">ISBN:*</label>
      <div class="col-sm-10">
         <input id="isbn" name="isbn" class="form-control input-lg" type="text" maxlength="150" placeholder="ISBN">
      </div>
    </div>
    <div class="form-group">
      <div class="col-sm-offset-2 col-sm-10">
         <span class="ms"></span><button type="button" id="okbutton" class="btn btn-success" style="float:right">下一步</button>
      </div>
    </div>
    </form>    
  </div>
  <div class="aside">
  <div class="indent">
    <p>感谢你为夜读书添砖加瓦，书籍添加成功后，你的名号将会永久保留在条目编辑页面。</p>
    <span class="">提示...</span>
    <p>请务必确认输入的书名、ISBN或统一书号的准确性，错误书号会导致重复创建等问题。</p>
    <p>系统可以识别ISBN的各种常用格式：10位或13位，有连接号或无连接号，比如7208086125、9787208086128以及978-7-208-08612-8是同一本书的ISBN，输入任一种都可以。</p>
    <p>统一书号的添加格式为：号码前加SH，用连接号衔接前后部分，如SH10009-476。</p>
  </div>
  </div>
</div>
</div>
<script>
$(document).ready(function(){
    $("#okbutton").click(function(){
        if($.trim($("#bookname").val())=="")
        {
            $(".ms").html("<font color='red'>请输入书籍的名字。</font>");
            $("#bookname").focus();
        }
        else if($.trim($("#isbn").val())=="")
        {
            $(".ms").html("<font color='red'>请输入书籍的ISBN。</font>");
            $("#isbn").focus();
        }
        else if($.trim($("#isbn").val())!="")
        {
            $.ajax({
              type:'post',
              url:'ajax/checkisbn',
              dataType:'html', 
              //async : true,
              data: $("form").serialize(),
              success:function(data) {
                if(data=="ok") {
                  $(".ms").html("<font color='red'>输入书籍的ISBN已经存在了(此书已经收录过了)。</font>");
                }
                else {
                  form.submit();
                }
              }
            });
        }
        else
        {
            form.submit();
        }
    });
});
</script>
@include('books.partials.footer')
</body>
</html>
